﻿using ConfigHelper.Common;
using DataAccessLayer.BaseInterface;
using IDataAccessLayer;
using Model.Extend_Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer
{
    public class Student_ExtendDataAcessLayer : BaseDataAccessLayer<Student_Extend>, IStudent_ExtendDataAcessLayer
    {
        public override string TableName
        {
            get
            {
                return "Student_Extend";
            }
        }

        public override Dictionary<string, bool> PKname
        {
            get
            {
                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("StudentId", false);
                return dic;
            }
        }

        public List<Student_Extend> GetStudentList(params SqlParameter[] param)
        {
            //调用common 中拼好的Sql语句
            string Sql = Common.GetStudentList<Student_Extend>(param);

            //调用DBHelper 返回DataTable类型
            DataTable dt = DBhelper.GetDataSet(Sql);

            List<Student_Extend> Student = new List<Student_Extend>();
            foreach (DataRow item in dt.Rows)
            {
                Student_Extend Students = new Student_Extend();
                foreach (var i in Students.GetType().GetProperties())
                {
                    i.SetValue(Students, item[i.Name]);
                }
                Student.Add(Students);
            }
            return Student;
        }
    }
}
